package com.csap.framework.oauth2;

import cn.dev33.satoken.oauth2.logic.type.GrantType;
import com.csap.framework.annotation.apidoc.ApiModel;
import com.csap.framework.annotation.apidoc.ApiModelProperty;
import com.csap.framework.annotation.apidoc.Group;
import com.csap.framework.annotation.apidoc.Request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;

/**
 * @author yangchengfu
 * @dataTime 2021年-08月-03日 13:02:00
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("公用参数")
public class BaseRequest<R> {
    @ApiModelProperty(value = "客户端ID", groups = {
            @Group(value = "authorize", request = @Request(required = true)),
            @Group(value = "token", request = @Request(required = true)),
            @Group(value = "refresh", request = @Request(required = true)),
            @Group(value = "doConfirm", request = @Request(required = true)),
            @Group(value = "password", request = @Request(required = true)),
            @Group(value = "client_token", request = @Request(required = true))
    })
    private String client_id;
    @ApiModelProperty(value = "客户端秘钥", groups = {
            @Group(value = "token", request = @Request(required = true)),
            @Group(value = "refresh", request = @Request(required = true)),
            @Group(value = "password", request = @Request(required = true)),
            @Group(value = "client_token", request = @Request(required = true))
    })
    private String client_secret;
    @ApiModelProperty(description = "授权类型", value = "授权类型", groups = {
            @Group(value = "token", request = @Request(required = true)),
            @Group(value = "refresh", request = @Request(required = true)),
            @Group(value = "password", request = @Request(required = true))
    })
    @NotEmpty(message = "授权类型不能为空")
    private GrantType grant_type;
    @ApiModelProperty(value = "登录的类型", forceReq = true)
    private String loginType;
    @ApiModelProperty(value = "用户的类型", forceReq = true)
    private String userType;
    @ApiModelProperty(value = "登录的设备", forceReq = true)
    private String deviceType;
    @ApiModelProperty(description = "平台标识", value = "平台标识", forceReq = true, required = true)
    private String platform;
    @ApiModelProperty(description = "作用域", value = "作用域", forceReq = true, required = true)
    private String scope;

    public R loginType(String loginType) {
        this.loginType = loginType;
        return (R) this;
    }

    public R deviceType(String deviceType) {
        this.deviceType = deviceType;
        return (R) this;
    }

    public R userType(String userType) {
        this.userType = userType;
        return (R) this;
    }

    public R platform(String platform) {
        this.platform = platform;
        return (R) this;
    }

    public R clientId(String client_id) {
        this.client_id = client_id;
        return (R) this;
    }

    public R clientSecret(String client_secret) {
        this.client_secret = client_secret;
        return (R) this;
    }

    public R grantType(GrantType grant_type) {
        this.grant_type = grant_type;
        return (R) this;
    }
}
